<?

header("Cache-control: private");
header("Content-type: application/" . (( $Engine->request->transfer_type == "js" )? "json": "x-javascript" ));


///// VALIDATE USER SESSION

if( !$Engine->user_session( 1 )) {

	?>

	window.location = "/";
	
	<?
} else {

///// BUILD COMMUNICATION SET

	if( $Engine->request->transfer_type != "js" ) { ?>
		
	ref	= $("<?= $Engine->request->trg ?>");
		
	<? }
	
	$objecttype = ( strpos( $Engine->request->type, "." ))?
		array_shift( explode( ".", $Engine->request->type, 2 )) : $Engine->request->type;
	
	
	
	
	if( file_exists ( $file = ROOT . ACCOUNT ."/custom.root/control/$objecttype.php" ) || file_exists ( $file = ENGINE_CORE ."control/request/$objecttype.php" ))
		include $file;
	
	else include ENGINE_CORE ."control/request/object.php";
	
	$ctrl		= "CTRL$objecttype";
	$Control = new $ctrl( $Request );
	
	echo $Control->{( !$Request->transfer_type || $Request->transfer_type == "win" )? "asset" : "ajax" }();
	
}